from .base import *
from decouple import config

# 在项目的根目录下新建.env文件，并按如下格式定义环境变量，decouple模块会自动找到
# 注意把.env文件名加到.gitignore中，如 echo '.env' >> .gitignore
# DEBUG=False
# SECRET_KEY = 'cf2a2ca82f2d4fae8be8f9d7b97f2a78'

DEBUG = config('DEBUG', cast=bool)
ALLOWED_HOSTS = ['*']

# 覆盖掉生产环境下的SECRET_KEY (生产方法：import uuid; print(uuid.uuid4().hex)
SECRET_KEY = config('SECRET_KEY', default='cf2a2ca82f2d4fae8be8f9d7b97f2a78')

## 数据库设置

# 使用PostgreSQL或者MySQL
# 如果使用MySQL需要在myweb/__init__.py文件中加入
# import pymsql
# pymysql.install_as_MySQLdb()
# 如果出现mysqlclient版本错误，加上下面一句
# pymysql.version_info=(1,3,13,"final",0)
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        # 'ENGINE': 'django.db.backends.postgresql',  # pipenv install psycopg2
        'NAME': config('DB_NAME'),
        'USER': config('DB_USER'),
        'PASSWORD': config('DB_PASSWORD'),
        'HOST': config('DB_HOST'),
        'PORT': config('DB_PORT'),
    }
}

# 生产环境下邮箱设置
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# SITE_HOST = config('SITE_HOST')
# EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=True)
# EMAIL_HOST = config('EMAIL_HOST')
# EMAIL_PORT = config('EMAIL_PORT')
#
# EMAIL_HOST_USER = config('EMIAL_HOST_USER')
# EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
# DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL')
